package android.gpsmessenger;

import java.util.*;

public class SimpleContactList 
{
	private List<Contact> _contactList;
	
	// constructors
	SimpleContactList()
	{
		_contactList = new ArrayList<Contact>(100);
	}

	SimpleContactList(SimpleContactList contactList)
	{
		Iterator<Contact> contactIterator = contactList.iterator();
		while(contactIterator.hasNext())
		{
			Contact c = (Contact) contactIterator.next();
			_contactList.add(c);
		}
	}	
	
	public List<Contact> getContactList()
	{
		return _contactList;
	}
	
	// other methods
	public void add(Contact contact)
	{
		_contactList.add(contact);
	}
	
	public void remove(Contact contact)
	{
		Iterator<Contact> contactIterator = _contactList.iterator();
		while(contactIterator.hasNext())
		{
			Contact c = (Contact) contactIterator.next();
			if (c.equals(contact))
			{
				_contactList.remove(c);
				break;
			}
		}
	}	
	
	public boolean contains(Contact contact)
	{
		Iterator<Contact> contactIterator = _contactList.iterator();
		while(contactIterator.hasNext())
		{
			Contact c = (Contact) contactIterator.next();
			if (c.equals(contact))
			{
				return true;
			}
		}
		return false;
	}
	
	public Iterator<Contact> iterator()
	{
	    return _contactList.iterator();
	}
	
	public int size()
	{
		return _contactList.size();
	}
	
	public Contact get(int index)
	{
		return _contactList.get(index);
	}
		
	public boolean isEmpty()
	{
		return _contactList.isEmpty();
	}
	
	public void clear()
	{
		_contactList.clear();
	}
	
	public String toString()
	{
		return (_contactList.toString());
	}	
	
}
